|
|
|
|
|
|
|
Generic object variables can refer to any form or any control on a form in your application. If you dont know the type of control that will be passed to a procedure, you need to use the generic Control keyword as the parameter type. If you write a procedure that affects forms in your application, you need to use the Form keyword as the parameter type. |
|
|
|
|
|
|
|
|
Besides the specific data types such as Integer, Double, and String, Visual Basic also allows you to declare and/or use variables that refer to particular visual objects in your application, such as forms and controls. |
|
|
|
|
|
|
|
|
Forms can be identified and classified by the following: |
|
|
|
|
|
|
|
|
The Name property of that particular form. This is actually a new kind of class. |
|
|
|
|
|
|
|
|
The class to which it belongs (in this case, Form, which is the generic object type). |
|
|
|
|
|
|
|
|
Controls can be identified and classified by the following: |
|
|
|
|
|
|
|
|
The Name property of that particular control. |
|
|
|
|
|
|
|
|
The class to which it belongs (in this case, Control, which is the generic object type). |
|
|
|
|
|
|
|
|
The specific object type that refers to the type of control, such as TextBox or ComboBox. |
|
|
|
|
|
|
|
|
What Do We Do with These Objects? |
|
|
|
|
|
|
|
|
The reason for learning about these objects is so that you can write more generic code. For example, you may want to accomplish the following with these objects: |
|
|
|
|
|
|
|
|
Center any form in your application |
|
|
|
|
|
|
|
|
Load a combo box or load a list box with one procedure |
|
|
|
|
|